package com.kelvin.paopao.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kelvin.kelvinlib.imageloader.GlideUtil;
import com.kelvin.paopao.R;
import com.kelvin.paopao.api.responseBean.PeisongModel;

/**
 * Created by MCK on 2017/5/8.
 */

public class MyRequestPeisongAdapter extends BaseQuickAdapter<PeisongModel, BaseViewHolder> {
    private Context context;

    public MyRequestPeisongAdapter(Context context) {
        super(R.layout.recyclerview_my_request_peisong_item);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, PeisongModel item) {
        ImageView iv = helper.getView(R.id.iv);
        GlideUtil.loadCommonImg(item.getSImg(), R.drawable.default_img, iv, context);
        helper.setText(R.id.tv_price, "￥" + item.getOprice());
        helper.setText(R.id.tv_number, "x" + item.getONum());
        helper.setText(R.id.tv_order_number, "订单编号：" + item.getoId());
        helper.setText(R.id.tv_order_time, "下单时间：" + item.getAddtime());
        helper.setText(R.id.tv_address, "配送地址：" + item.getOuser() + "(" + item.getUser_name() + ") " +
                item.getOtel() + " " + item.getLname());
        helper.setText(R.id.tv_good_name, item.getSName());
        helper.setText(R.id.tv_states, item.getStates() == 0 ? "待确定" : "已接受");
        helper.setTextColor(R.id.tv_states, item.getStates() == 0 ?
                ContextCompat.getColor(mContext, android.R.color.holo_red_light) :
                ContextCompat.getColor(mContext, R.color.text_color_hint));
    }
}
